package memento.fromCSDN.once;

/**
 * 原发器:象棋棋子类
 */
public class Chessman {
    private String label;

    private int x;
    private int y;

    public Chessman() {
    }

    public Chessman(String label) {
        this.label = label;
    }

    public Chessman(String label, int x, int y) {
        this.label = label;
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    //保存状态
    public ChessmanMemento save(){
        return new ChessmanMemento(this.label,this.getX(),this.getY());
    }

    //恢复状态
    public void restore(ChessmanMemento menento){
        this.label = menento.getLabel();
        this.x = menento.getX();
        this.y = menento.getY();
    }

}
